<script setup>

//注册按钮
import router from "@/router/index.js";
import {ref} from "vue";

const register = ()=>{
  router.push({name:'Register'})
}
const userData = ref({
  username:'',
  password:'',
})

//重置数据
const resetUserData = ()=>{
  userData.value.password=''
  userData.value.password=''
}

import {loginService} from "@/api/User.js";
//登录
const login = async ()=>{
  const result = await loginService(userData.value)
  if (result.code===0){
    router.push({name:'LayOut'})
  }else if(result.code===2){
    const messageHTML = document.querySelector('.message')
    messageHTML.innerHTML=result.msg
    setTimeout(()=>{
      messageHTML.innerHTML=''
    },2000)
  }
}
</script>
<template>
  <div class="bg">
  <div class="container">
    <div class="row">
      <div class="col-md-8">
        <div class="font-left">
          <p>
            <h1>智能简历分析系统</h1>
          </p>
          <p>
            <h3>My dream is the starry sea, and you?</h3>
          </p>
        </div>
      </div>
      <div class="col-md-4">
        <div class="t1">
          <div class="dltop">

            <h1 class="text-center">欢迎登录</h1>

          </div>
          <div>
            <form>
                <div class="row">
                  <div class="col-md-2">
                    <p class="text-center font-denglu">
                        账号
                    </p>
                  </div>
                  <div class="col-md-9">
                    <input type="text" class="form-control" placeholder="请输入账号" name="pswd" v-model="userData.username">
                  </div>
                </div>

                <div class="row">
                    <div class="col-md-2">
                      <p class="text-center font-denglu">
                          密码
                      </p>
                    </div>
                    <div class="col-md-9">
                      <input type="password" class="form-control" placeholder="请输入密码" name="pswd" v-model="userData.password">
                    </div>
                </div>
                  <div class="row">
                    <div class="col-md-2"></div>
                    <div class="col-md-6">
                        <!-- <label class="form-check-label"> -->
                          <input class="form-check-input" type="checkbox" name="remember"> Remember me
                        <!-- </label> -->
                      </div>
                    </div>
                  <div class="message">

                  </div>
                  <div class="col-md-12 text-center btn">
                        <button type="button" class="btn btn-primary col-md-3 btn-l" @click="login()">登录</button>
                        <button type="button" class="btn btn-primary col-md-3 btn-r" @click="register()">注册</button>
                  </div>
              </form>
        </div>

        </div>
      </div>
    </div>
  </div>
  </div>
</template>

<style scoped>
.bg{
  background-image: url(../../assets/images/2b29d1d0d8690b37173dcddfd091f75.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  width: 100%;
  height: 100%;
  position: fixed;
  left: 0;
  top: 0;
}
.t1{
  margin:100px 0 200px 0;
  height: 400px;
  border: 2px white;
  border-radius: 10%;
  background-color: rgba(255, 255, 255, 0.56);
  box-shadow: 10px 10px 10px 10px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(5px);
}
.font-left{
  color:white;
  text-align: center;
  margin:200px auto 200px auto;
}
.dltop{
  height: 120px;
  margin-top: 50px;
  margin-bottom: 10px;
}
.dltop h1{
  line-height: 120px;
}
.font-denglu{
    line-height: 38px;
    /* font-size: larger; */
    font-weight: bolder;
}
form{
    padding-left: 20px;
}
.row{
    margin-bottom: 8px;
    margin-top: 5px;
}
.btn-l{
    margin-right: 30px;
    /* margin-left: 20px; */
}
.btn-r{
    margin-left: 30px;
}
.btn{
    margin-top: 5px;
}
.message{
  margin-left: 160px;
  font-size: large;
  font-weight: bolder;
  color: red;
}
</style>